import _ from 'lodash'
import { add, Maybe } from './util.js'

const liftA2 = _.curry(function(f, functor1, functor2) {
    return functor1.map(f).ap(functor2)
})

const liftA3 = _.curry(function(f, functor1, functor2, functor3) {
    return functor1.map(f).ap(functor2).ap(functor3)
})

const v1 = liftA2(add, Maybe.of(2), Maybe.of(3))
console.log(v1)

console.log(`
操作符。在 haskell, scala, PureScript 中，开发者可以自定义中缀操作符号 infix operators。
如在 haskell 中：add <$> Right 2 <*> Right3 . 这里 <$> 就是 map, <*> 就是 ap
`)